package cn.swust.designpatternlearningplatform.dao.sql;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

public class TopicKnowledgePointDaoSql {
    public String selectKnowledgePointById(@Param("id") Integer id) {
        SQL sql = new SQL();
        sql.SELECT("point_id", " parent_id", "point_content");
        sql.FROM("knowledge_point");

        if (id == null) {
            sql.WHERE("parent_id IS NULL");
        } else {
            sql.WHERE("parent_id = " + id);
        }
        return sql.toString();
    }
    /**
     * @param topicKnowledge:
      * @return String
     * @author wang
     * description 通过知识点内容查询知识点id
     * date 2023/5/28 13:01
     */
    public String selectPointIdByContent(String topicKnowledge){
        return new SQL(){
            {
                SELECT("point_id");
                FROM("knowledge_point");
                WHERE("point_content=#{topicKnowledge}");
            }
        }.toString();
    }
}
